<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../common/admin.asp"-->
<%
conn.execute("update sms set isRead=1 where type='1' and uid='"&request.QueryString("uid")&"'")
'分页-------------------------------------------------------
set Rs=server.CreateObject("ADODB.RecordSet")
sql="select count(sortid) from (Select ROW_NUMBER() OVER (order by id desc ) as sortid,* From sms) as TempTable where 1=1 and uid='"&request.QueryString("uid")&"'"
Pager_Pagesize=20 '每页记录数
Rs.open sql,conn,1,1
Pager_TotalRecord=Rs(0) '总记录数
Rs.close
Pager_PageCount=int((Pager_TotalRecord/Pager_Pagesize)+0.99999) '计算总页数
CurrentPage=Request("page") '当前页
'如果不为数字则直接设置页码为1
if isnumeric(CurrentPage)=False Or CurrentPage="" then
	CurrentPage=1
'如果当前页数大于总页数，则直接设置页码为1
elseif  Clng(CurrentPage)>Pager_PageCount then
	CurrentPage=1
end if
Fieldsname=" id,uid,[Order],[Content],type,isRead,addtime,sortid"
orderBy=" Order by sortid asc"
'拆分SQL语句，必须是select开头，有唯一标识的列
if instr("select",sql)<>-1 then
	if CurrentPage = 1 then
		sql = replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize  & Fieldsname)
	else  
		sql = replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize   & Fieldsname) & " and sortid >(select max(sortid) from (" & replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize * (CurrentPage - 1)  & Fieldsname) & orderBy & ") AA)"
	end if
end if
sql = sql & orderBy
Rs.open sql,conn,1,1
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>add</title>
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
</head>

<body>
<div class="main">
  <div class="main-title">操作</div>
  <div class="main-content">
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <form action="" method="post">
  <tr>
    <td bgcolor="#FFFFFF">订单号</td>
    <td bgcolor="#FFFFFF"><input name="order" type="text" class="input" id="order" value="" /></td>
  </tr>
  <tr>
    <td width="21%" bgcolor="#FFFFFF">内容</td>
    <td width="79%" bgcolor="#FFFFFF"><textarea name="content" cols="40" rows="5" class="content-input"></textarea></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF"><input type="submit" name="button" id="button" value="签写" />
      </td>
  </tr>
    </form>
  </table>
  
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <form action="" method="post">
  <tr>
    <td width="6%" align="center"><strong>选择</strong></td>
    <td width="6%" align="center">来源</td>
    <td width="10%" align="center">订单号</td>
    <td width="69%" align="center"><strong>内容</strong></td>
    <td width="9%"><strong>添加时间</strong></td>
    </tr>
    <%do while not Rs.eof%>
  <tr>
    <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="checkbox" id="checkbox" value="<%=rs("id")%>" /></td>
    <td align="center" bgcolor="#FFFFFF" ><%if rs("type")="1" then response.Write rs("uid") else response.Write rs("type")%></td>
    <td align="center" bgcolor="#FFFFFF" ><%=rs("order")%></td>
    <td bgcolor="#FFFFFF" ><%=rs("content")%></td>
    <td bgcolor="#FFFFFF"><%=rs("addtime")%></td>
    </tr>
    <%
	Rs.movenext
	loop
	Rs.close
	Set Rs=nothing
	%>
    <tr>
      <td colspan="5" align="center" bgcolor="#FFFFFF" class="page">
<input type="submit" name="button" id="button" value="删除" /> 
      </td>
    </tr>
    </form>
    <tr>
    <td colspan="5" align="center" bgcolor="#FFFFFF" class="page">　
      <%
	siteurl=request.servervariables("document_name")
	%>
    <form action="<%=siteurl%>" method="get">
    共 <%=Pager_TotalRecord%> 条 第<%=CurrentPage%>页 / 共 <%=Pager_PageCount%> 页
		<%
		pageurl="key="&key&"&id="&request.QueryString("id")&"&uid="&request.QueryString("uid")&"&search="&search&"&"
		if CurrentPage=1 then
			response.Write(" 首页 ")
			response.Write(" 上一页 ")
		else
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page=1'>首页</a> ")
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page="& (CurrentPage-1) &"'>上一页</a> ")
		end if
		%>
		<%
		if Clng(CurrentPage)=Clng(Pager_PageCount) then
			response.Write(" 下一页 ")
			response.Write(" 尾页 ")
		else
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page="& (CurrentPage+1) &"'>下一页</a> ")
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page="& Pager_PageCount &"'>尾页</a> ")
		end if
		%>
		&nbsp;
		<input name="page" type="text" value="<%=CurrentPage%>" size="1" maxlength="10" />
        <input type="submit" name="button" value="跳转" />
        <input type="hidden" name="key" value="<%=key%>" />
        <input type="hidden" name="uid" value="<%=request.QueryString("uid")%>" />
        <input type="hidden" name="id" value="<%=request.QueryString("id")%>" />
        <input type="hidden" name="search" value="搜索" />
        </form>
      </td>
    </tr>
  </table>
</div>
</div>
</body>
</html>
<%
checkbox=request.Form("checkbox")
if checkbox<>"" then	
	if request.Form("button")="删除" then
		conn.execute("delete from sms where id in("&checkbox&")")
	end if
	response.Redirect "Reply.asp?uid="&request.QueryString("uid")&"&page="&request.QueryString("page")&""
end if



if request.Form("button")="签写" then

	  uid=request.QueryString("uid")
	  content=request.Form("content")
	  order=request.Form("order")

	  if uid="" or content="" then
	  response.write"<script>alert('内容不能为空');</script>"
	  response.write"<script>window.history.back(-1);</script>"
	  response.end
	  end if
	  
	  set rsx=server.createobject("adodb.recordset")
	  sql="select * from sms"
	  rsx.open sql,conn,1,3
	  rsx.addnew
	  rsx("uid")=uid
	  rsx("content")=content
	  rsx("type")=request.cookies("admin")("name")
	  rsx("content")=content
	  if order<>"" then rsx("order")=order
	  rsx.update
	  response.write"<script language=JavaScript>{window.alert('提交成功！');window.location.href='Reply.asp?uid="&uid&"';}</script>"
	  rsx.close
	  set rsx=nothing

end if
%>